<?php
/**
 * Created by Dumitru Russu
 * User: developer
 * Date: 9/21/12
 * Time: 9:42 AM
 * To change this template use File | Settings | File Templates.
 */
class Db_Products_ProductPageTextColor extends Common {

	protected static $tableName = TAB_PRODUCT_PAGE_TEXT_COLOR;
	protected static $dbFields = array(
		'id',
		'pptc_loyout_item_id',
		'pptc_design_id',
		'pptc_color',
		'pptc_text',
		'pptc_line_height',
		'pptc_font_family',
		'pptc_font_size',
		'pptc_text_align',
		'pptc_vertical_align',
		'deleted'
	);

	/**
	 * @var Db_Products_ProductPageTextColor
	 */
	public $objectArray;

	public $id;
	public $pptc_loyout_item_id;
	public $pptc_design_id;
	public $pptc_color;
 	public $pptc_text;
 	public $pptc_line_height;
 	public $pptc_font_family;
 	public $pptc_font_size;
 	public $pptc_text_align;
 	public $pptc_vertical_align;
	public $deleted;

	function __construct($value = null, $filedName = null) {
		parent::__construct($value, $filedName);
	}

	/**
	 * TIn this method I return for flash default text color for designs
	 * @static
	 * @return array
	 */
	public static function getAllProductPageTextColor() {
		$textColors = self::$DB->q('SELECT * FROM ?f ;', self::$tableName);
		$allProductsPageTextColors = array();
		while($data = $textColors->fetch_assoc()) {
			$allProductsPageTextColors[$data['pptc_design_id']][] = $data;
		}
		return $allProductsPageTextColors;
	}

	/**
	 * This function used in flash
	 *
	 * @static
	 * @param array $liIds
	 * @return bool
	 */
	public static function deleteByLiIds($liIds = array()) {
		$liIdsList = implode(',', $liIds);
		self::$DB->q("DELETE FROM ?f WHERE `pptc_loyout_item_id` IN( ? )", self::$tableName, $liIdsList);

		return (self::$DB->mysqlModifiedRows() > 0 ? true : false);
	}

}
